package com.EAIPClub.UserBaseInfoDataManager.controller;

import com.EAIPClub.UserBaseInfoDataManager.service.UserBaseInfoDataManagerService;
import com.api.POJO.UserBaseInfoManager.BaseInfo;
import com.api.POJO.UserBaseInfoManager.BaseInfoReturnMsg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description :用户基本信息管理模块控制层
 * @Author :崔昌赫
 * @Date : 2021/10/21
 */

@RestController
@Slf4j
public class UserBaseInfoDataManagerController {

    private UserBaseInfoDataManagerService userBaseInfoDataManagerService;

    @Autowired
    public void setUserBaseInfoDataManagerService(UserBaseInfoDataManagerService userBaseInfoDataManagerService) {
        this.userBaseInfoDataManagerService = userBaseInfoDataManagerService;
    }

    @GetMapping("/users/base/info/get/all")
    BaseInfoReturnMsg findAllBaseInfo(){
        return userBaseInfoDataManagerService.findAllBaseInfo();
    }

    @PostMapping("/users/base/info/add")
    BaseInfoReturnMsg addNewBaseInfo(@RequestBody BaseInfo baseInfo){
        log.info("接收到数据:{}",baseInfo);
        return userBaseInfoDataManagerService.addNewBaseInfo(baseInfo);
    }

    @GetMapping("/users/base/info/get/uid/{uid}")
    BaseInfoReturnMsg findBaseInfoByUid(@PathVariable String uid){
        log.info("接收到数据:{}",uid);
        return userBaseInfoDataManagerService.findBaseInfoByUid(uid);
    }
    @GetMapping("/users/base/info/get/name/{name}")
    BaseInfoReturnMsg findBaseInfoByName(@PathVariable String name){
        log.info("接收到数据:{}",name);
        return userBaseInfoDataManagerService.findBaseInfoByName(name);
    }
    @GetMapping("/users/base/info/get/class/{classes}")
    BaseInfoReturnMsg findBaseInfoByClass(@PathVariable String classes){
        log.info("接收到数据:{}",classes);
        return userBaseInfoDataManagerService.findBaseInfoByClass(classes);
    }
    @GetMapping("/users/base/info/get/studentid/{studentId}")
    BaseInfoReturnMsg findBaseInfoByStudentId(@PathVariable String studentId){
        log.info("接收到数据:{}",studentId);
        return userBaseInfoDataManagerService.findBaseInfoByStudentId(studentId);
    }

    @PutMapping("/users/base/info/update/uid/{uid}")
    BaseInfoReturnMsg updateBaseInfoByUid(@PathVariable String uid,@RequestBody BaseInfo baseInfo){
        log.info("接收到数据:{},{}",uid,baseInfo);
        return userBaseInfoDataManagerService.updateBaseInfoByUid(uid, baseInfo);
    }
    @PutMapping("/users/base/info/update/name/{name}")
    BaseInfoReturnMsg updateBaseInfoByName(@PathVariable String name,@RequestBody BaseInfo baseInfo){
        log.info("接收到数据:{},{}",name,baseInfo);
        return userBaseInfoDataManagerService.updateBaseInfoByName(name, baseInfo);
    }
    @PutMapping("/users/base/info/update/class/{classes}")
    BaseInfoReturnMsg updateBaseInfoByClass(@PathVariable String classes,@RequestBody BaseInfo baseInfo){
        log.info("接收到数据:{},{}",classes,baseInfo);
        return userBaseInfoDataManagerService.updateBaseInfoByClass(classes, baseInfo);
    }
    @PutMapping("/users/base/info/update/studentid/{studentId}")
    BaseInfoReturnMsg updateBaseInfoByStudentId(@PathVariable String studentId,@RequestBody BaseInfo baseInfo){
        log.info("接收到数据:{},{}",studentId,baseInfo);
        return userBaseInfoDataManagerService.updateBaseInfoByStudentId(studentId, baseInfo);
    }

    @DeleteMapping("/users/base/info/delete/uid/{uid}")
    BaseInfoReturnMsg deleteBaseInfoByUid(@PathVariable String uid){
        log.info("接收到数据:{}",uid);
        return userBaseInfoDataManagerService.deleteBaseInfoByUid(uid);
    }
    @DeleteMapping("/users/base/info/delete/name/{name}")
    BaseInfoReturnMsg deleteBaseInfoByName(@PathVariable String name){
        log.info("接收到数据:{}",name);
        return userBaseInfoDataManagerService.deleteBaseInfoByName(name);
    }
    @DeleteMapping("/users/base/info/delete/class/{classes}")
    BaseInfoReturnMsg deleteBaseInfoByClass(@PathVariable String classes){
        log.info("接收到数据:{}",classes);
        return userBaseInfoDataManagerService.deleteBaseInfoByClass(classes);
    }
    @DeleteMapping("/users/base/info/delete/studentid/{studentId}")
    BaseInfoReturnMsg deleteBaseInfoByStudentId(@PathVariable String studentId){
        log.info("接收到数据:{}",studentId);
        return userBaseInfoDataManagerService.deleteBaseInfoByStudentId(studentId);
    }

}
